package com.lgy.ms.service.service.other;

import com.lgy.ms.api.other.IAsyncService;
import com.lgy.ms.core.domain.ServiceLog;
import com.lgy.ms.service.dao.ServiceLogDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author Gylin
 */
@Service(value = "asyncService")
public class AsyncServiceImpl implements IAsyncService {

	private Logger log = LoggerFactory.getLogger(AsyncServiceImpl.class);

	@Resource
	private ServiceLogDao serviceLogDao;

	@Async
	@Override
	public void saveServiceLog(ServiceLog serviceLog) {
		long threadId = Thread.currentThread().getId();
		log.debug("exec saveServiceLog thread id :" + threadId);
		try {
			serviceLogDao.insert(serviceLog);
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}
	}
}
